<!DOCTYPE html>
<html lang="zh_CN" xmlns:th="http://www.thymeleaf.org"
  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,user-scalable=no, initial-scale=1">
		<title>客户详情</title>
		<link rel="stylesheet" type="text/css" href="/azxcrm/css/wap/mui.min.css" th:href="@{/azxcrm/css/wap/mui.min.css}"/>
		<link rel="stylesheet" type="text/css" href="/azxcrm/css/wap/mui.picker.min.css" th:href="@{/azxcrm/css/wap/mui.picker.min.css}"/>
		<link rel="stylesheet" type="text/css" href="../static/azxcrm/css/wap/aui.css" th:href="@{/azxcrm/css/wap/aui.css}"/>
		<link rel="stylesheet" type="text/css" href="../static/azxcrm/css/wap/retreat.css" th:href="@{/azxcrm/css/wap/retreat.css}"/>
		<link rel="stylesheet" type="text/css" href="//at.alicdn.com/t/font_835360_5n3z54a5m1.css"/>
		<script src="/azxcrm/js/wap/mui.min.js" th:src="@{/azxcrm/js/wap/mui.min.js}" type="text/javascript" charset="utf-8"></script>
		<script src="/azxcrm/js/wap/mui.picker.min.js" th:src="@{/azxcrm/js/wap/mui.picker.min.js}" type="text/javascript" charset="utf-8"></script>
		<script src="../static/js/jquery.min.js" th:src="@{/js/jquery.min.js}"></script>
		<script th:inline="javascript"> var ctx = [[@{/}]]; </script>
	</head>
	<body>
		<header class="aui-bar aui-bar-nav">
			 <a href="javascript:history.back(-1)"  class="aui-pull-left aui-btn">
	       		 <span class="iconfont icon-fanhui1">返回</span>
	    	</a>
		    <div class="aui-title">退单</div>
		</header>
		
		<section class="aui-grid aui-margin-b-15">
			<div class="aui-content aui-margin-b-15 g-order2">
			<ul class="aui-list aui-form-list">
		        <li class="aui-list-header">
					<div class="s-order">
						<div>请填写退单说明</div>
					</div>
					<span id="orderId"  th:text="${orderId}" style="display:none"></span>
		        </li>
				<li class="aui-list-item g-text">
		            <div class="aui-list-item-inner">
		                <div class="aui-list-item-input">
		                    <textarea placeholder="请填写退单原因" id="refundsReason"></textarea>
		                </div>
		            </div>
		        </li>
		    </ul>
		    <div class="aui-bar aui-bar-tab">
		        <a class="aui-bar-tab-item" id="toastBtn" onclick="cancelOrder()">                   
		            <div class="aui-bar-tab-label">提交</div>
		        </a>           
			 </div>
		</div>
	</section>
	</body>
</html>
<script>
	function cancelOrder(){
		var btnArray = ['否', '是'];
		var orderId=$("span[id='orderId']").text();
		var refundReason=$("textarea[id='refundsReason']").val();		
		 mui.confirm("是否要发起退单吗？",btnArray, function(e){
			 if(e.index == 1){
				 $.ajax({
			            cache : true,
			            type : "POST",
			            url : ctx + "/wap/order/refund",
			            data : {
							"orderId" : orderId,
							"refundReason" : refundReason
			            },
			            async : false,
			            error : function(request) {
			                mui.toast("系统错误");
			            },
			            success : function(data) {
			                if (data.msg == 1) {
			                    mui.toast("发起退单成功!"); 
			                    $("#toastBtn").removeAttr("onclick");
			                    setTimeout(function(){
			                        window.location.href= ctx + "/wap/order/followOrder"},2200)
			                } else {
			                    mui.toast("发起退单失败!");
			                }
			            }
			        });	 
			 }

		 })
	} 
</script>